<template>
  <div>
    <input v-model="value" />
    <span>子组件：{{ props.modelValue }}</span>
  </div>
</template>

<script setup lang="ts">
import { computed } from "vue";

const props = defineProps({ modelValue: String });

let emit = defineEmits(["update:modelValue"]);
// 2.使用 v-model
const value = computed({
  get() {
    return props.modelValue;
  },
  set(value) {
    emit("update:modelValue", value);
  },
});
</script>
